package string;

public class StringBuilderDemo {
    public static void main(String[] args) {
        /*
        //StringBuilder的创建方式
        StringBuilder builder1=new StringBuilder();
        StringBuilder builder2=new StringBuilder("abc");

        //String和StringBuilder的互转
        String str="abc";
        StringBuilder builder=new StringBuilder(str);
        String str2=builder.toString();
         */

        String str="好好学习Java";
        StringBuilder builder=new StringBuilder(str);
        //追加
        builder.append(",为了找个好工作");
        System.out.println(builder);
        //替换(含头不含尾)
        builder.replace(13,14,"更好");
        System.out.println(builder);//好好学习Java,为了找个更好的工作
        //删除(含头不含尾)
        builder.delete(0,9);
        System.out.println(builder);//为了更好的工作
        //插入
        builder.insert(2,"找到");
        System.out.println(builder);//为了找到更好的工作

    }
}
